package com.wk.wanjetpack.db

import androidx.paging.PagingSource
import androidx.room.*
import com.wk.wanjetpack.bean.Article
import kotlinx.coroutines.flow.Flow

/**
 * @author peng
 * @date 2021/1/25
 * 说明
 */
@Dao
interface ArticleDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertArticles(articles: List<Article>)

    @Delete
    fun deleteArticle(article: Article)

    @Query("DELETE FROM articles")
    fun deleteAll()

    @Update
    fun updateArticle(article: Article)

    @Query("SELECT * FROM articles")
    suspend fun getAllArticles(): List<Article>

    @Query("SELECT * FROM articles WHERE pageIndex = :pageIndex")
    suspend fun getArticlesByPage(pageIndex:Int): List<Article>

}